#※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
# File Name: install_jupyter.sh
# Author: GID5564
# Description:
# Created Time: 01/12/23-21:11:36
#※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
#! /usr/bin/env bash

function __jupyter_init__(){
    msg "jupyter相关软件包安装中…"
    install_dpkg_packages "clang,libzmq5"
    install_python_packages "jupyter,notebook,autopep8"
    
    #install_python_packages "jupyter_nbextensions_configurator"
    #install_python_packages "jupyter_contrib_nbextensions"
    
    #eval "jupyter contrib nbextension install"
    #eval "jupyter nbextensions_configurator enable" 
    
    #__snippets__
    local cur=$(pwd)
    sudo chmod 777 ~/.local/share/jupyter && cd ~/.local/share/jupyter && sudo chmod 777 runtime
    cd $cur
}




function InstallCKernel(){
    
     if [[ $(command -v install_c_kernel) ]];then
          tip "${RED}install_c_kernel${RESET}${BLUE} 软件包已存在，无需重复安装!${RESET}"
    else
        msg "${GREEN}install_c_kernel软件包安装中…… ${RESET}" 
        eval "${COMMAND_PIP_INSTALL} jupyter-c-kernel"
        install_c_kernel
        
    fi
    
}
function InstallZshKernel(){
    msg "${GREEN}zsh内核安装中…… ${RESET}" 
    InstallPip "ipykernel"
    python3 -m ipykernel install --user --name zsh --display-name "zsh"
    success "zsh内核安装成功!"
}
function __snippets__(){

    chmod 777 ${FILE_SNIPPET}
    mv -vf ${FILE_SNIPPET} ${FILE_SNIPPET%/*}/snippets.json_bk
    config_snippets
}



function config_snippets(){
    cat >${FILE_SNIPPET} <<-'EOF'
{
    "snippets" : [
        {
            "name":"Py文件头",
            "code":[
                "# ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※",
                "# @File: $0",
                "# @Author: Gid5564",
                "# @Description: ",
                "# @Time: $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE",
                "# @Version: 1.0",
                "# ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※",
                " ",
                "#!/usr/bin/python",
                "# -*- coding: UTF-8 -*-"
                ]
        },
        {
            "name":"函数注释",
            "code":[
                "'''",
                "  功能描述: ",
                "  参数: ",
                "  返回: ",
                "'''"
                ]
        },
        {
            "name":"添加模块路径",
            "code":[
                "'''",
                "# 模块路径根据自己的修改。",
                "'''"
                "import os",
                "import sys",
                "BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))",
                "sys.path.append(BASE_DIR)",
                "#接后续代码",
                ""
                ]
        },
        {
            "name":"C文件头",
            "code":[
                "/* ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※",
                "> @File: $0",
                "> @Author: Gid5564",
                "> @Description: ",
                "> @Time: $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE",
                "> @Version: 1.0",
                " ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※",
                "*/ ",
                " ",
                "//%cflags:-lm",
                " ",
                "#include <stdio.h>",
                "#include <stdlib.h>"
                ]
        }
    ]
}


EOF
}












